package com.easyapi.server.observation;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: javadadi
 * @Time: 14:19
 * @ClassName: AbstractBeObserver
 */
public class AbstractBeObserver implements BeObserver {
    private List<Observer> list;

    public AbstractBeObserver(List<Observer> list) {
        this.list = list;
    }

    @Override
    public void addObserver(Observer observer) {
        list.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        list.remove(observer);
    }

    @Override
    public void notifyObservers(String action, Long id) {
        for (Observer observer : list) {
            observer.update(action, id);
        }
    }
}
